﻿<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/revoelectric.master" Title="Accounts | Revo" CodeFile="Accounts.aspx.cs" Inherits="Accounts" %>

<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="head">
</asp:Content>

<asp:Content ID="Content2" runat="server" ContentPlaceHolderID="widebarHeaderContentPlaceHolder">

</asp:Content>

<asp:Content runat="server" ID="generatebill_content" ContentPlaceHolderID="widebarBodyContentPlaceHolder">
    <form id="formCustomerGrid" runat="server">
        <div>
		    <asp:GridView ID="GridViewAccounts" runat="server" 
                AllowSorting="True" AutoGenerateColumns="False" DataSourceID="ccDb" 
                EnableModelValidation="True" BackColor="White" BorderColor="#999999" 
                BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Vertical" 
                AllowPaging="True" DataKeyNames="meter_id" DataMember="DefaultView" 
                ShowFooter="True">
                <AlternatingRowStyle BackColor="#DCDCDC" />
                <Columns>
                    <asp:BoundField DataField="customer_id" HeaderText="Customer Id" 
                        SortExpression="customer_id" />
                    <asp:BoundField DataField="trn" HeaderText="TRN#" 
                        SortExpression="trn" ReadOnly="true" />
                    <asp:BoundField DataField="first_name" HeaderText="First Name" 
                        SortExpression="first_name" ReadOnly="true" />
                    <asp:BoundField DataField="last_name" HeaderText="Last Name" 
                        SortExpression="last_name" ReadOnly="true" />
                    <asp:BoundField DataField="meter_id" HeaderText="Meter Id" 
                        SortExpression="meter_id" ReadOnly="true" /> 
                    <asp:CommandField ShowEditButton="True" />
                </Columns>
                <FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
                <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
                <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
                <RowStyle BackColor="#EEEEEE" ForeColor="Black" />
                <SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
            </asp:GridView>
            <asp:SqlDataSource ID="ccDb" runat="server" 
                ConnectionString="<%$ ConnectionStrings:onwindConnectionString %>" 
                SelectCommand="sp_getAllAccounts" SelectCommandType="StoredProcedure"
                InsertCommand="sp_createCustomerAccountByTrn" InsertCommandType="StoredProcedure"
                UpdateCommand="sp_updateCustomerAccount" UpdateCommandType="StoredProcedure">
                <UpdateParameters>
                    <asp:Parameter Name="customer_id"  Type="Int32" />
                    <asp:Parameter Name="meter_id" Type="Int32" />
                    <asp:Parameter Name="result" Type="Int32" Direction="Output" />
                </UpdateParameters>
            </asp:SqlDataSource>
        </div>
        <div>
            <asp:FormView ID="FormViewCustomer" runat="server" BackColor="White" 
                BorderColor="#999999" BorderStyle="None" BorderWidth="1px" CellPadding="3" 
                DataSourceID="ccDb" EnableModelValidation="True" GridLines="Vertical" 
                DataKeyNames="id" DefaultMode="Insert">
                                    
                <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
                <InsertItemTemplate>
                    <h3>Add New Customer Account</h3>
                    <span class="txtLabel">TRN#:</span>
                    <asp:TextBox ID="txtTrn" runat="server" 
                        Text='<%# Bind("trn") %>' />
                    <br />
                    <span class="txtLabel">Meter Id:</span>
                    <asp:TextBox ID="first_nameTextBox" runat="server" 
                        Text='<%# Bind("meter_id") %>' />
                    <br />
                    <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" 
                        CommandName="Insert" Text="Insert" />
                    &nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server" 
                        CausesValidation="False" CommandName="Cancel" Text="Cancel" />
                </InsertItemTemplate>
            </asp:FormView>
        </div>
    </form>
</asp:Content>